/**
 * Created by Administrator on 2017/3/27.
 */
app.controller('loginCtr',
['$scope','$location','$http','$rootScope','$timeout', function ($scope,$location,$http,$rootScope,$timeout) {
    
    $scope.clearN=function () {
        if($scope.user.user_name){
            $scope.user.user_name="";
        }
    };

    // 存储会员信息
    $rootScope.loginInfor="";

    $scope.togEye=false;
    $scope.togglPwd=function () {
        $scope.s=$("#pwd").attr("type");
        if( $scope.s=="password"){
           $("#pwd").attr("type","text");
           $scope.togEye=false;
        }else{
            $("#pwd").attr("type","password");
            $scope.togEye=true;
        }
    };

    //普通登录方法
    $scope.submitLogin=function () {
        var tel=$scope.user.user_name;
        var pwd=$scope.user.user_pwd;
        var devid=111;
        $http.post('http://172.19.32.122:9080/sso-app/login',{phone:tel,devid:devid,password:pwd},{'Content-Type':'application/x-www-form-urlencoded'}).success(function(data){
            console.log("ss");
            $scope.industries = data;
        });
        // $.post("http://172.19.32.67:8080/login",{phone:tel,devid:devid,password:pwd},function(result){
        //         if(result.code==1){
        //             $rootScope.loginInfor=result.value;
        //             $rootScope.devid=devid;
        //             $scope.token=result.value.token;
        //             $scope.logMssg=result.msg;
        //             $rootScope.isUseLog=true;
        //             $timeout(function(){
        //                 $scope.jump('/home');
        //             },1000);
        //         }else if(result.code==0){
        //             $scope.logMssg=result.msg;
        //             $scope.user.user_pwd="";
        //             $scope.user.user_name="";
        //         }
        //     },function (erro) {
        //         console.log(erro);
        // });
        // $http({
        //     url:'http://172.19.47.154:8080/nanfang_if/discuss',
        //     method:'post',
        //     headers:{'Content-Type':'application/x-www-form-urlencoded'},
        //     data:{
        //         phone:tel,devid:devid,password:pwd
        //     },
        //     success:function (data) {
        //         console.log("登录");
        //         console.log(data);
        //     }
        // })

    };
    
    //第三放登录方法
    $scope.submitTrdLogin=function () {
        // sharSDK
        $.post("http://172.19.32.67:8080/login",{phone:tel,devid:devid,password:pwd},function(result){
            // $scope.provider=
            // $scope.oid=
            // $scope.nickname=
            // $scope.devid=
            // $scope.head=
        },function (erro) {
        });

        //
        $.post("http://172.19.32.67:8080/loginByOther",{provider:$scope.provider,oid:$scope.oid,nickname:$scope.nickname,devid:$scope.devid,head:$scope.head},function(res){
            if(result.code==1){
                $rootScope.loginInfor=result.value;
                $rootScope.devid=devid;
                $scope.token=result.value.token;
                $scope.logMssg=result.msg;
                $rootScope.isUseLog=true;
                $timeout(function(){
                    $scope.jump('/home');
                },1000);
            }else if(result.code==0){
                $scope.logMssg=result.msg;
                $scope.user.user_pwd="";
                $scope.user.user_name="";
            }
        },function (erro) {
        });
    }

}]);




